﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MeetFuture.MRC.Commands
{
    public class AGVCommand
    {
        public static string MissionStatusQuery(ICommandSupplemental supplemental, clsAGVInfo agvInfo, string missionId = null)
        {
            var cmd = $"MissionStatus MissionId=";
            if (missionId != null)
            {
                cmd = $"MissionStatus MissionId={missionId}";
            }
            var command = new BasicCommand();
            return command.SendSync(supplemental, agvInfo, cmd);
        }
        public static string ExtractStatus(string message)
        {
            var msg = message.Replace("\r", string.Empty);
            string[] splitMsg = msg.Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string RecMessage in splitMsg)
            {
                string head = ApplicationGlobal.GetValueByKey(RecMessage, "EVENT");
                switch (head.ToUpper())
                {
                    case "MISSIONSTATUS":
                        string status = ApplicationGlobal.GetValueByKey(RecMessage, "AGVSTATUS");
                        return status;
                }
            }
            return "Unknown";
        }
    }
}
